package com.my.blogs.personblog.mapper;

import com.my.blogs.personblog.enity.Root;
import com.my.blogs.personblog.enity.User;
import com.my.blogs.personblog.enity.information;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface RootMapper {
    @Select("select * from personalblog.root where id=#{id}")
    public List<Root> selectAllUsers();
    @Select("select * from personalblog.root where id=#{id}")
    public Root selectUserById(int id);
    @Select("select * from personalblog.root where username=#{username}")
    public Root selectUserByUsername(String username);
    @Select("select * from personalblog.root where email=#{email}")
    public Root selectUserByEmail(String email);
    @Select("select * from personalblog.root where phone=#{phone}")
    public Root selectUserByPhone(String phone);
    @Insert("insert into personalblog.root (username, password, email, phone, IdCard) values (#{username}, #{password}, #{email}, #{phone}, #{IdCard})")
    public Boolean insertUser(User user);
    @Update("update personalblog.root set username=#{username}, password=#{password}, email=#{email}, phone=#{phone}, IdCard=#{IdCard} where id=#{id}")
    public Boolean updateUser(User user);
    @Delete("delete from personalblog.root where id=#{id}")
    public Boolean deleteUser(int id);
    @Select("select * from personalblog.root order by id=#{id}")
    public List<Root> sortById(int id);
    @Select("select * from personalblog.root limit #{page},#{pageSize}")
    public List<Root> selectPage(int page, int pageSize);
    @Select("select *from personalblog.information")
    public List<information> selectInformation();
    @Insert("insert into personalblog.information (title,content,NovelKind,HotWord,CreateDate,UpdateDate) values (#{title},#{content},#{NovelKind},#{HotWord},#{CreateDate},#{UpdateDate}")
    public information insertInformation(information information);
    @Update("update personalblog.information set title=#{title},content=#{content},NovelKind=#{NovelKind},HotWord=#{HotWord},CreateDate=#{CreateDate},UpdateDate=#{UpdateDate} where id=#{id}")
    public Boolean updateInformation(information information);
    @Delete("delete from personalblog.information where id=#{id}")
    public Boolean deleteInformation(int id);
}
